﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Objects;
using HMP;

namespace HMP.BL
{
    class CheckDataExist
    {
        public bool KiemTra(string temp)
        {
            //Chuỗi chứa thông tin kết nối đến cơ sở dữ liệu
            string strConn = "Data Source=ADMIN0305WRN;Initial Catalog=QUAN LI THONG TIN BENH NHAN;Persist Security Info=True;User ID=sa;Password=123456";
            //Khai báo đối tượng dùng kết nối CSDL
            SqlConnection con = new SqlConnection(strConn);

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from tbUser where Telephone= " + temp;

            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                // ton tai
                return false;
            }
            else
            {
                // chua co
                return true;
            }
        }
    }
}
